﻿#region Creditos

/* Autor: Edilberto Sánchez Forero	*/
/* Email: esanchezfo@gmail.com		*/
/* Licencia: LGPL, Software Libre	*/
/* País: Colombia, Bogotá			*/

#endregion

#region Librerias

using System;
using ESF.General.Entity;

#endregion


namespace ESF.General.MVP
{
	public class BasePresenter<I> where I : IBaseViewer
	{
		#region Members

		protected Type [] _ExtraSerializableTypes;

		#endregion


		#region Viewer
		
		protected I _Viewer;
		
		#endregion
		
		
		#region Constructor
		
		protected BasePresenter (params Type [] pExtraSerializableTypes) 
		{
			_ExtraSerializableTypes = pExtraSerializableTypes;
		}
		
		
		public BasePresenter (I pViewer) : this ()
		{
		    _Viewer = pViewer;
		}
		
		#endregion
		
		
		#region Funciones
		
		public virtual void Clear () 
		{
		}
		
		
		public virtual void Load () {}
		
		
		public void SetSavedMsg ()
		{
			_Viewer.frmInfoMsg = "Los datos han sido almacenados";
		}
		
		public void SetDeletedMsg ()
		{
			_Viewer.frmInfoMsg = "El(Los) elemento(s) seleccionado(s) han sido eliminado(s)";
		}
		
		
		public void LogError (Exception pEx)
		{
			Log.Error (pEx);
			
			_Viewer.frmErrorMsg = GenericException.GetClientMessage (pEx);
		}
		
		
		public void ClearError ()
		{
			_Viewer.frmErrorMsg = string.Empty;
		}
		
		#endregion
	}
}
